<script setup>
import { ref, onMounted } from 'vue'
import axios from 'axios'
import Navbar from '@/components/Navbar.vue'
import RoomPanel from '@/components/RoomPanel.vue'
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL;  // 从环境变量获取基础 URL

const homeLinks = ref([
  {name: '入住与退房服务', to: '/waiter'},
]);

const all_rooms = ref();  // 现在我们从后端获取房间数据


onMounted(async () => {
  await fetchRooms();
});

async function fetchRooms() {
  try {
    const response = await axios.get(`${apiBaseUrl}/waiter/get_room_state`);
    console.log(response.data)
    all_rooms.value = response.data;
  } catch (error) {
    console.error('Failed to fetch rooms:', error);
  }
}
</script>

<template>
  <div>
    <Navbar :links="homeLinks"/>
    <RoomPanel :all_rooms="all_rooms" />
  </div>
</template>

<style scoped>
/* 如果需要，可以在这里添加针对该视图的特定样式 */
</style>
